var t, a, e, n, i, u = require("../../utils/util.js"), o = getApp().globalData.url.imgurl, s = getApp().globalData.url.apiUrl, r = new Array();

Page({
    data: {
        imgurl: o,
        backurl: "",
        inputshow: !1,
        inputvalue: "",
        watermark: 0
    },
    onLoad: function(o) {
        i = 0, t = o.micro_id, a = o.log_id, e = this, r = new Array(), u.getToken(function(a) {
            n = a, u.sendrequest("posterapi/getsetup", "POST", {
                token: a,
                id: t
            }, function(t) {
                if (1 == t.status) {
                    e.setData({
                        backurl: t.data.background_path,
                        width: t.data.background_width,
                        height: t.data.background_height,
                        watermark: t.data.watermark,
                        steuplist: t.data.setuplist
                    });
                    for (var a = 0; a < t.data.setuplist.length; a++) {
                        var n = new Object();
                        n.id = t.data.setuplist[a].id, n.content = t.data.setuplist[a].content, r = r.concat(n);
                    }
                }
            });
        });
    },
    onShow: function() {},
    showinput: function(t) {
        var a = t.currentTarget.dataset.index;
        i = a, this.setData({
            inputvalue: r[i].content,
            inputshow: !0
        });
    },
    inputclose: function() {
        e.setData({
            inputshow: !1,
            inputvalue: ""
        });
    },
    inputreset: function() {
        e.setData({
            inputvalue: ""
        });
    },
    frontconfirm: function(t) {
        r[i].content = t.detail.value;
        var a = e.data.steuplist;
        a[i].content = r[i].content, e.setData({
            inputshow: !1,
            steuplist: a
        });
    },
    Submit: function(e) {
        u.getToken(function(t) {
            u.sendrequest("posterapi/addmnum", "POST", {
                token: t,
                id: a,
                formid: e.detail.formId
            }, function(t) {});
        }), wx.showLoading({
            title: "生成中",
            mask: !0
        }), wx.downloadFile({
            url: s + "posterapi/generatedynamic?id=" + t + "&token=" + n + "&txt=" + JSON.stringify(r),
            success: function(t) {
                wx.hideLoading(), 200 === t.statusCode && wx.previewImage({
                    current: 0,
                    urls: [ t.tempFilePath ]
                });
            }
        });
    }
});